package com.yuanli.cosmeticmirror.bean;


import com.comenjoysoft.baselibrary.util.SPUtils;
import com.yuanli.cosmeticmirror.utils.CommonUtils;
import com.yuanli.cosmeticmirror.utils.FileUtils;

/**
 * 用户作品、录音、本地文件可使用
 */
public class UserWork {

    private String aId;
    private String userId;
    /**作品：1，录音：2 */
    private int aTypeCode;
    private String aName;
    /**音频时长 毫秒*/
    private long duration;
    /**最后修改时间 秒 */
    private long aLastModifyTime;
    private String aPath;
    /**大小 */
    private String aSizeStr;

    /**是否选中 temp*/
    private boolean isSelect;
    /**是否正在播放 temp*/
    private boolean isPlay;
    /**播放开始时间 temp*/
    private long playStartTime;
    /**播放结束时间 temp*/
    private long playEndTime;
    /**当前音量（默认-1） temp */
    private int vol = -1;

    /**用户作品类型*/
    public static final String WORK_TYPE_CODE = "workTypeCode";
    /**作品*/
    public static final int TYPE_CODE_WORK = 1;
    /**录音*/
    public static final int TYPE_CODE_RECORDER = 2;

    public UserWork() {
        this.aId = CommonUtils.getUniqueNumber();
    }


    /**
     * @param userId 用户id
     * @param aTypeCode 作品类型 作品/录音
     * @param aName 作品名称
     * @param duration 时长
     * @param aLastModifyTime 最后修改时间
     * @param aPath 完整的存储路径
     * @param aSizeStr 大小
     */
    public UserWork(String userId, int aTypeCode, String aName, long duration, long aLastModifyTime, String aPath, String aSizeStr) {
        this.aId = CommonUtils.getUniqueNumber();
        this.userId = userId;
        this.aTypeCode = aTypeCode;
        this.aName = aName;
        this.duration = duration;
        this.aLastModifyTime = aLastModifyTime;
        this.aPath = aPath;
        this.aSizeStr = aSizeStr;
    }


//    /**
//     * 转换一个素材
//     * @param material
//     * @return
//     */
//    public static UserWork getUserWork(UserMaterial material){
//        UserWork userWork = new UserWork();
//        if (material != null){
//            userWork.setaName(material.getName());
//            userWork.setaPath(material.getPath());
//            userWork.setaSizeStr(material.getStrSize());
//            userWork.setDuration(material.getDuration());
//            userWork.setaTypeCode(UserWork.TYPE_CODE_WORK);
//        }
//        return userWork;
//    }
//
//    /**
//     * 创建音频作品
//     * @param filePath 完整路径
//     * @return
//     */
//    public static UserWork createWorkAudio(String filePath){
//        String userId = SPUtils.getUserId();
//        return new UserWork(
//                userId,
//                UserWork.TYPE_CODE_WORK,
//                FileUtils.getFileName(filePath,true),
//                MyAudioUtil.getAudioTime(filePath),
//                RxTimeTool.getCurTimeMills(),
//                filePath,
//                RxFileTool.getFileSize(filePath));
//    }

    public String getaId() {
        return aId;
    }

    public void setaId(String aId) {
        this.aId = aId;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public int getaTypeCode() {
        return aTypeCode;
    }

    public void setaTypeCode(int aTypeCode) {
        this.aTypeCode = aTypeCode;
    }

    public String getaName() {
        return aName;
    }

    public void setaName(String aName) {
        this.aName = aName;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public long getaLastModifyTime() {
        return aLastModifyTime;
    }

    public void setaLastModifyTime(long aLastModifyTime) {
        this.aLastModifyTime = aLastModifyTime;
    }

    public String getaPath() {
        return aPath;
    }

    public void setaPath(String aPath) {
        this.aPath = aPath;
    }

    public boolean isSelect() {
        return isSelect;
    }

    public void setSelect(boolean select) {
        isSelect = select;
    }

    public boolean isPlay() {
        return isPlay;
    }

    public void setPlay(boolean play) {
        isPlay = play;
    }

    public long getPlayStartTime() {
        return playStartTime;
    }

    public void setPlayStartTime(long playStartTime) {
        this.playStartTime = playStartTime;
    }

    public long getPlayEndTime() {
        return playEndTime;
    }

    public void setPlayEndTime(long playEndTime) {
        this.playEndTime = playEndTime;
    }

    public int getVol() {
        return vol;
    }

    public void setVol(int vol) {
        this.vol = vol;
    }

    public String getaSizeStr() {
        return aSizeStr;
    }

    public void setaSizeStr(String aSizeStr) {
        this.aSizeStr = aSizeStr;
    }

    @Override
    public String toString() {
        return "UserWork{" +
                "aId='" + aId + '\'' +
                ", userId='" + userId + '\'' +
                ", aTypeCode=" + aTypeCode +
                ", aName='" + aName + '\'' +
                ", duration=" + duration +
                ", aLastModifyTime=" + aLastModifyTime +
                ", aPath='" + aPath + '\'' +
                ", isSelect=" + isSelect +
                ", isPlay=" + isPlay +
                '}';
    }
}
